package com.wenxixuanwu.fruitstore.service.impl;

import com.wenxixuanwu.fruitstore.Vo.ProductVo;
import com.wenxixuanwu.fruitstore.entity.Product;
import com.wenxixuanwu.fruitstore.mapper.DetailsMapper;
import com.wenxixuanwu.fruitstore.service.DetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DetailsServiceImpl implements DetailsService {

    @Autowired
  private DetailsMapper detailsMapper;

    @Override
    public ProductVo selectById(int id) {
        ProductVo pv = detailsMapper.selectById(id);
        return pv;
    }

    @Override
    public int getById(int id) {
        int kid = detailsMapper.getById(id);
        return kid;
    }

    @Override
    public List<Product> selectByKind(int id) {
       if (detailsMapper.selectByKind(id).size()>1){
           return detailsMapper.selectByKind(id);
       }else {
           return detailsMapper.selectAll();
       }
    }

    @Override
    public List<Product> selectAll() {
        return detailsMapper.selectAll();
    }


}
